<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="layout :: common_header(~{::title})">
    <title>拣货中订单 - WMS仓库管理系统</title>
</head>
<body th:replace="layout :: common_body(~{::div.layui-body})">

<div class="layui-body" style="padding:15px;">
    <style type="text/css">
        .T-box {
            width: 400px;
            padding: 0 20px;
            text-align: left;
        }

        .T-box p {
            position: relative;
            height: 36px;
            line-height: 36px;
            font-size: 14px;
            margin-bottom: 15px;
        }

        .T-box p span {
            display: inline-block;
            padding-right: 15px;
            text-align: right;
            width: 110px;
            line-height: 36px;
            font-size: 14px;
        }

        .T-box p input, .T-box p select {
            width: 160px;
            padding: 0 5px;
            height: 34px;
            line-height: 34px;
            font-size: 14px;
            border: 1px solid #d3d3d3;
            outline: none;
        }

        .T-box p i {
            padding: 0 10px;
            line-height: 36px;
            font-style: normal;
        }

        .T-box p b {
            display: inline-block;
            margin-left: 10px;
            cursor: pointer;
            width: 60px;
            height: 36px;
            line-height: 36px;
            background: #c33;
            color: #fff;
            text-align: center;
            font-size: 13px;
            font-weight: normal;
        }

        .T-result {
            margin-bottom: 0;
        }

        .T-result em {
            color: #c33;
            font-style: normal;
        }
    </style>

    <!-- content starts -->
    <!--    <blockquote class="layui-elem-quote">待发货订单</blockquote>-->

    <fieldset class="layui-elem-field">
        <legend>按条件搜索</legend>
        <div class="layui-field-box">
            <form class="layui-form layui-form-pane1" method="get" action="/order/order_picking_list">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <input type="text" name="orderNum" placeholder="订单编号" class="layui-input">
                    </div>
<!--                    <div class="layui-inline">-->
<!--                        <input type="text" name="mjMobile" placeholder="买家手机号" class="layui-input">-->
<!--                    </div>-->
                    <div class="layui-inline">
                        <input type="text" name="logisticsCode" placeholder="物流单号" class="layui-input">
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">订单时间</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="startTime" id="startTime"
                                   placeholder="yyyy-MM-dd" autocomplete="off">
                        </div>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="endTime" id="endTime" placeholder="yyyy-MM-dd"
                                   autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button type="submit" class="layui-btn">搜索</button>
                        <i>总共：&nbsp;[[${totalSize}]]&nbsp;条记录</i>
                    </div>
                    <div class="layui-inline"></div>

                </div>
            </form>



        </div>
    </fieldset>

    <!--<div class="layui-inline"> <button class="layui-btn">批量发货</button></div>-->
    <!--<div class="layui-inline"> <a class="layui-btn" href="/order/printSendListOne">打印发货单模板1</a></div>-->
    <!--<div class="layui-inline"> <a class="layui-btn" href="/order/printSendListTwo">打印发货单模板2</a></div>-->

    <!-- start dd-wrapper -->
    <link rel="stylesheet" href="/css/order.css"/>
    <div class="dd-wrapper">
        <form method="post">
            <table class="dd-table">
                <tr>
                    <th>ID</th>
                    <th>订单信息</th>
                    <th width="">商品信息</th>
                    <th >收货信息</th>
                    <th >物流信息</th>
                    <th>订单来源</th>
                    <th>销售类型</th>
                    <th>订单备注</th>
                    <th>状态</th>
                    <!--                    <th>操作</th>-->
                </tr>
                <tr th:each="item:${lists}">
                    <td>
                        <input th:if="${item.status == 0}" type="checkbox" class="ids" name="ids"
                               th:value="${item.id}"/>[[${item.id}]]
                    </td>
                    <td>
                        <p>订单号：<span th:text="${item.order_num}"></span></p>
                        <p>下单时间：<span th:text="${#dates.format(item.orderTime * 1000,'yyyy-MM-dd HH:mm:ss')}"></span></p>
                        <p>开始拣货时间：<span th:text="${#dates.format(item.pickingTime * 1000,'yyyy-MM-dd HH:mm:ss')}"></span></p>
                    </td>
                    <td>
                        <div>
                            总共<span style="color: red;font-size: large">[[${item.totalQuantity}]]</span> 件商品<p><i class="goods_list" th:attr="data-id=${item.getId()}" style="color: #1E9FFF">查看详情</i></p>

                        </div>
                    </td>
                    <td>
                    <p><span th:text="${item.logisticsCompany}"></span>&nbsp;</p>
                    <p><span th:text="${item.logisticsCode}"></span></p>
                </td>
                    <td>
                        <p>收货人：<span th:text="${item.contactPerson}"></span>&nbsp;<span th:text="${item.mobile}"></span></p>
                        <p>
                            <span th:text="${item.province}"></span>
                            <span th:text="${item.city}"></span>
                            <span th:text="${item.area}"></span></p><p>
                            <span th:text="${item.address}"></span>
                        </p>
                    </td>
                    <td th:text="${item.shopName}"></td>
                    <td >
                        <span th:if="${item.saleType == 0}">样品</span>
                        <span th:if="${item.saleType == 1}">实售</span>
                    </td>
                    <td >
                        <span th:text="${item.sellerMemo}"></span>
                        <span th:text="${item.remark}"></span>
                    </td>
                    <td>

                        <b th:text="${T(com.b2c.wms.enums.EnumErpOrderSendStatus).getName(item.status)}"></b>
                    </td>

                    <!--                    <td>-->
                    <!--                        <i class="print" th:attr="data-id=${item.id}">打印采购单</i>-->
                    <!--                        <a class="print" href="javascript:;" th:attr="data-id=${item.id}">打印</a>-->
                    <!--                    </td>-->
                </tr>
            </table>
        </form>
    </div>
    <!-- end dd-wrapper -->
    <div class="layui-box layui-laypage layui-laypage-default pageBox">
        <paging:pager th:value="${pageIndex}" th:rows="${totalSize}" th:size="${pageSize}"/>
    </div>

    <script type="text/template" id="send-goods">
        <div class="T-box">
            <p><span>快递公司</span>
                <select id="send-company">
                    <option value="">请选择快递公司</option>
                    <option value="yunda">韵达快递</option>
                </select>
            </p>
            <p><span>快递单号</span><input type="text" id="send-number"/></p>
            <p><span>订单编号</span><i id="order-num"></i></p>
            <p><span>下单时间</span><i id="order-time"></i></p>
            <p><span>付款时间</span><i id="pay-time"></i></p>
            <p class="T-result"><span>&nbsp;</span><em id="erro"></em></p>
        </div>
    </script>

    <script src="/js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript">
        layui.use(['laydate', 'layer'], function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: '#startTime'
            });
            laydate.render({
                elem: '#endTime'
            });
        });
        var r = /^\+?[1-9][0-9]*$/;
        $(function () {

            //弹出商品list
            $(".goods_list").click(function () {
                var id = $(this).attr("data-id");
                layer.open({
                    type: 2,
                    title: '订单商品列表',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['940px', '90%'],
                    content: '/order/order_goods_list?id=' + id //iframe的url
                });
            })
            //(按订单生成拣货单)
            $("#exportPrintOrder").click(function () {
                var ids = [];
                $("input[name^='ids']").each(function (i, el) {
                    if ($(this).is(':checked'))
                        ids.push($(this).val());
                });
                console.log(ids);
                if (ids.length == 0)
                    alert("请选择订单");
                else {
                    if (confirm("你选中的订单将会生成拣货单，确认要操作吗？")) {
                        $.ajax({
                            url: "/ajax_order/generating_picking_list_by_order",
                            type: "POST",
                            dataType: "json",
                            contentType: "application/json",
                            data: JSON.stringify({id: ids}),
                            success: function (res) {
                                console.log("加入拣货清单");
                                console.log(res);
                                if (res.code == 0) {
                                    alert("成功," + res.data);
                                    window.location.reload();
                                } else {
                                    alert(res.msg);
                                }
                            },
                            complete: function(XMLHttpRequest){
                                if (XMLHttpRequest.getResponseHeader("REDIRECT")=="NO_ACCESS")alert("无权限访问");
                            },
                        });
                    }
                }
            });


            //AJAX 上传菜鸟订单excel
            // $("#excel_upload_btn").click(function () {
            //     var excel = $("#excel").val();
            //     if (excel == '') {
            //         alert("请选择文件");
            //         return false;
            //     } else if (excel.lastIndexOf(".xls") < 0) {//可判断以.xls和.xlsx结尾的excel
            //         alert("只能上传Excel文件");
            //     } else if (excel.lastIndexOf(".xlsx") > 0) {
            //         alert("只能上传Excel文件");
            //     } else {
            //
            //
            //         var url = "/ajax_order/order_send_excel";
            //         var formData = new FormData($('#execl_form')[0]);
            //
            //         // var formData = new FormData();
            //         // formData.append("excel", document.getElementById("excel").files[0]);
            //         if (confirm("请确保你的excel是从菜鸟打印系统中导出的excel。你确定吗？")) {
            //
            //
            //             $.ajax({
            //                 url: url,
            //                 type: "post",
            //                 data: formData,
            //                 success: function (result) {
            //                     if (result.code == 0) {
            //                         alert("更新成功:" + result.data);
            //                         window.location.reload();
            //                     } else {
            //                         alert("更新失败:" + result.msg());
            //                     }
            //
            //                     // alert(JSON.stringify(result));
            //                     return false;
            //                 },
            //                 error: function () {
            //                     alert("excel上传失败");
            //                 },
            //                 cache: false,
            //                 contentType: false,
            //                 processData: false
            //             });
            //         }
            //     }
            //
            //     return false;
            // })
        });
    </script>
</div>


</body>
<html>
